﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Demo610
{
    public partial class register : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (args.Value == "admin")
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            //判断表单所有信息是否无误
            if (Page.IsValid)
            {
                //将用户名添加到Session对象中
                Session.Add("username", TextBox1.Text);
                //将用户名添加到Session对象中
                Session.Add("password", TextBox2.Text);
                //将Literal1显示内容修改成提示 和一个a标签
                Literal1.Text = $"注册成功...<a href=\"login.aspx\">点此去登陆</a>";
            }
        }
    }
}